<?php
 
class MydatasController extends AppController {
     
    public $name = "mydatas";  // なくてもいい
    public $uses = "Mydata";   // なくてもいい
    public $autoRender = true; // なくてもいい
    public $layout = "sample";
    public $autoLayout = true; // なくてもいい    
     
    function index(){
        $this->set("page_title","Sample Page");
        $this->set("content_header","Sample Page.");
        $this->set("content_footer","copyright SYODA-Tuyano. 2010.");
 
        $datas = $this->Mydata->find("all");
        $this->set("datas",$datas);
    }
    
    function add(){
        $this->set("page_title","Sample Add Page");
        $this->set("content_header","Sample 編集画面よ。.");
        $this->set("content_footer","copyright SYODA-Tuyano. 2010.");
 
        if (!empty($this->data)){
            $this->Mydata->save($this->data);	
            $this->redirect(".");
        }
    }
    
    function edit(){
        $this->set("page_title","サンプル編集画面よedit .");
        $this->set("content_header","Sample ヘッダー Page.");
        $this->set("content_footer","copyright SYODA-Tuyano. 2010.");
 
 		echo 'var_dump = ';
        echo $this->data;
 
        if (!empty($this->data)){
            $this->Mydata->save($this->data);
            $this->redirect(".");
        } else {
            $id = $this->params["url"]["id"];
            $this->data = $this->Mydata->findById($id);
        }
    }
    
 
}

?>